<?php
/**
 * Created by PhpStorm.
 * User: Happy
 * Date: 2017/1/8 0008
 * Time: 11:26
 */

class baidu_ocrPlugin extends Plugin
{
   private    $aipOcr = null;
    public  function  __construct($path='')
    {
        parent::__construct($path);
        $path=$this->c('plugin_path');
        $lib_path=$path.'/AipOcr.php';
        include($lib_path);
        $config=$this->config;
        $app_id=$config['app_id'];
        $app_key=$config['api_key'];
        $secret_key=$config['secret_key'];
        $this->aipOcr=new AipOcr($app_id, $app_key, $secret_key);
    }
  //读取图片信息
    public function  read_image($base_64_image=''){
        $aipOCR=$this->aipOcr;
        if(!$base_64_image){return false;}

        $result=$aipOCR->general2Api($base_64_image);

        if($result&&$result['words_result']){
            $words=$result['words_result'];
            return $words;
        }
        else{
            return false;
        }
    }



}